import cv2
import numpy as np
import matplotlib.pyplot as plt

o = cv2.imread("D:\\xiuzhi.jpg", 0)
f = np.fft.fft2(o)
ftshift = np.fft.fftshift(f)
magnitude_spectrum = 20 * np.log(np.abs(ftshift))
plt.subplot(121)
plt.imshow(o, cmap='gray')
plt.title('original')
plt.axis('off')
plt.subplot(122)
plt.imshow(magnitude_spectrum, cmap='gray')
plt.title('result')
plt.axis('off')
plt.show()
